package com.bytedance.improvingroad.scroll_conflict

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.widget.ListView
import kotlin.math.abs

/**
 * Created by chenxiong
 * date 12/21/21
 */
class MyListView @JvmOverloads constructor(context: Context, attributeSet: AttributeSet? = null, style:Int = 0):
    ListView(context,attributeSet,style) {
    private var lastX = 0f
    private var lastY = 0f
    //1. 内部拦截法
//    override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
//        when(ev?.action) {
//            MotionEvent.ACTION_DOWN -> {
//                parent.requestDisallowInterceptTouchEvent(true)
//            }
//            MotionEvent.ACTION_MOVE -> {
//                if (abs(ev.x-lastX) > abs(ev.y-lastY)) {
//                    parent.requestDisallowInterceptTouchEvent(false)
//                }
//            }
//        }
//        lastX = ev?.x ?: 0f
//        lastY = ev?.y ?: 0f
//        return super.dispatchTouchEvent(ev)
//    }
}